<template>
  <div class="app-container">
    <div class="sidebar">
      <div class="sidebar-header">
        <div class="logo">
          <i class="logo-icon">🚀</i>
          <h2>WhuOps</h2>
        </div>
        <div class="logo-subtitle">Kubernetes 运维平台</div>
      </div>
      <ul class="sidebar-menu">
        <li :class="{ active: activeSection === 'welcome' }" @click="handleSectionClick('welcome')">
          <i class="menu-icon">🏠</i>
          <span>首页</span>
        </li>
        <li :class="{ active: activeSection === 'agent' }" @click="handleSectionClick('agent')">
          <i class="menu-icon">🤖</i>
          <span>AI 助手</span>
        </li>
        <li :class="{ active: activeSection === 'terminal' }" @click="handleSectionClick('terminal')">
          <i class="menu-icon">💻</i>
          <span>智能终端</span>
        </li>
        <li :class="{ active: activeSection === 'monitor' }" @click="handleSectionClick('monitor')">
          <i class="menu-icon">📊</i>
          <span>集群监控</span>
        </li>
        <li :class="{ active: activeSection === 'fault' }" @click="handleSectionClick('fault')">
          <i class="menu-icon">⚠️</i>
          <span>故障监控</span>
        </li>
      </ul>
      
      <div class="sidebar-footer">
        <div class="status-info">
          <div class="status-item">
            <span class="status-dot online"></span>
            <span>系统在线</span>
          </div>
          <div class="version">v1.0.0</div>
        </div>
      </div>
    </div>
    
    <div class="main-content">
      <div class="content-wrapper">
        <WelcomeSection v-if="activeSection === 'welcome'" :is-active="true" @navigate="handleSectionClick" />
        <AgentSection v-if="activeSection === 'agent'" :is-active="true" />
        <SmartTerminalSection v-if="activeSection === 'terminal'" :is-active="true" />
        <MonitorSection v-if="activeSection === 'monitor'" :is-active="true" />
        <FaultSection v-if="activeSection === 'fault'" :is-active="true" />
      </div>
    </div>
  </div>
</template>

<script>
import { ref } from 'vue'
import WelcomeSection from './components/WelcomeSection.vue'
import AgentSection from './components/AgentSection.vue'
import SmartTerminalSection from './components/SmartTerminalSection.vue' // 新增导入
import MonitorSection from './components/MonitorSection.vue'
import FaultSection from './components/FaultSection.vue'

export default {
  name: 'App',
  components: {
    WelcomeSection,
    AgentSection,
    SmartTerminalSection, // 新增组件
    MonitorSection,
    FaultSection
  },
  setup() {
    const activeSection = ref('welcome');

    const handleSectionClick = (section) => {
      activeSection.value = section;
    };

    return {
      activeSection,
      handleSectionClick
    };
  }
}
</script>

<style>
/* 保持原有的样式不变 */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: #f5f7fa;
  overflow-x: hidden;
}

.app-container {
  display: flex;
  min-height: 100vh;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.sidebar {
  width: 280px;
  background: rgba(0, 21, 41, 0.95);
  backdrop-filter: blur(20px);
  color: white;
  display: flex;
  flex-direction: column;
  box-shadow: 4px 0 20px rgba(0, 0, 0, 0.1);
  border-right: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-header {
  padding: 30px 25px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.logo-icon {
  font-size: 32px;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

.logo h2 {
  font-size: 28px;
  font-weight: 700;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.logo-subtitle {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.7);
  margin-left: 44px;
  font-weight: 400;
}

.sidebar-menu {
  flex: 1;
  list-style: none;
  padding: 20px 0;
}

.sidebar-menu li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 25px;
  cursor: pointer;
  transition: all 0.3s ease;
  margin: 2px 15px;
  border-radius: 12px;
  font-weight: 500;
  position: relative;
  overflow: hidden;
}

.sidebar-menu li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  width: 0;
  height: 100%;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  transition: width 0.3s ease;
  z-index: 0;
}

.sidebar-menu li:hover::before {
  width: 100%;
}

.sidebar-menu li:hover {
  color: white;
  transform: translateX(5px);
}

.sidebar-menu li.active {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.sidebar-menu li.active::before {
  width: 100%;
}

.menu-icon {
  font-size: 20px;
  z-index: 1;
  position: relative;
}

.sidebar-menu li span {
  font-size: 15px;
  z-index: 1;
  position: relative;
}

.sidebar-footer {
  padding: 20px 25px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.status-info {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.status-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.8);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  animation: blink 2s infinite;
}

.status-dot.online {
  background: #52c41a;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.version {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.5);
  text-align: center;
}

.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.content-wrapper {
  flex: 1;
  position: relative;
  overflow: hidden;
}

.content-section {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px);
  transition: all 0.3s ease;
  background: white;
  border-radius: 20px 0 0 0;
  box-shadow: -4px 0 20px rgba(0, 0, 0, 0.1);
  overflow: hidden;
}

.content-section.active {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

/* 响应式设计 */
@media (max-width: 768px) {
  .sidebar {
    width: 250px;
  }
  
  .logo h2 {
    font-size: 24px;
  }
  
  .sidebar-menu li {
    padding: 14px 20px;
  }
}

@media (max-width: 640px) {
  .sidebar {
    width: 200px;
  }
  
  .sidebar-header {
    padding: 20px 15px;
  }
  
  .sidebar-menu li {
    padding: 12px 15px;
    margin: 2px 10px;
  }
}
</style>